'\" t
.\"     Title: git-gc
.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 07/27/2015
.\"    Manual: Git Manual
.\"    Source: Git 2.5.0
.\"  Language: English
.\"
.TH "GIT\-GC" "1" "07/27/2015" "Git 2\&.5\&.0" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-gc \- Cleanup unnecessary files and optimize the local repository
.SH "SYNOPSIS"
.sp
.nf
\fIgit gc\fR [\-\-aggressive] [\-\-auto] [\-\-quiet] [\-\-prune=<date> | \-\-no\-prune] [\-\-force]
.fi
.sp
.SH "DESCRIPTION"
.sp
Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance) and removing unreachable objects which may have been created from prior invocations of \fIgit add\fR\&.
.sp
Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance\&.
.sp
Some git commands may automatically run \fIgit gc\fR; see the \-\-auto flag below for details\&. If you know what you\(cqre doing and all you want is to disable this behavior permanently without further considerations, just do:
.sp
.if n \{\
.RS 4
.\}
.nf
$ git config \-\-global gc\&.auto 0
.fi
.if n \{\
.RE
.\}
.sp
.SH "OPTIONS"
.PP
\-\-aggressive
.RS 4
Usually
\fIgit gc\fR
runs very quickly while providing good disk space utilization and performance\&. This option will cause
\fIgit gc\fR
to more aggressively optimize the repository at the expense of taking much more time\&. The effects of this optimization are persistent, so this option only needs to be used occasionally; every few hundred changesets or so\&.
.RE
.PP
\-\-auto
.RS 4
With this option,
\fIgit gc\fR
checks whether any housekeeping is required; if not, it exits without performing any work\&. Some git commands run
git gc \-\-auto
after performing operations that could create many loose objects\&.
.sp
Housekeeping is required if there are too many loose objects or too many packs in the repository\&. If the number of loose objects exceeds the value of the
gc\&.auto
configuration variable, then all loose objects are combined into a single pack using
git repack \-d \-l\&. Setting the value of
gc\&.auto
to 0 disables automatic packing of loose objects\&.
.sp
If the number of packs exceeds the value of
gc\&.autoPackLimit, then existing packs (except those marked with a
\&.keep
file) are consolidated into a single pack by using the
\-A
option of
\fIgit repack\fR\&. Setting
gc\&.autoPackLimit
to 0 disables automatic consolidation of packs\&.
.RE
.PP
\-\-prune=<date>
.RS 4
Prune loose objects older than date (default is 2 weeks ago, overridable by the config variable
gc\&.pruneExpire)\&. \-\-prune=all prunes loose objects regardless of their age\&. \-\-prune is on by default\&.
.RE
.PP
\-\-no\-prune
.RS 4
Do not prune any loose objects\&.
.RE
.PP
\-\-quiet
.RS 4
Suppress all progress reports\&.
.RE
.PP
\-\-force
.RS 4
Force
git gc
to run even if there may be another
git gc
instance running on this repository\&.
.RE
.SH "CONFIGURATION"
.sp
The optional configuration variable \fIgc\&.reflogExpire\fR can be set to indicate how long historical entries within each branch\(cqs reflog should remain available in this repository\&. The setting is expressed as a length of time, for example \fI90 days\fR or \fI3 months\fR\&. It defaults to \fI90 days\fR\&.
.sp
The optional configuration variable \fIgc\&.reflogExpireUnreachable\fR can be set to indicate how long historical reflog entries which are not part of the current branch should remain available in this repository\&. These types of entries are generally created as a result of using git commit \-\-amend or git rebase and are the commits prior to the amend or rebase occurring\&. Since these changes are not part of the current project most users will want to expire them sooner\&. This option defaults to \fI30 days\fR\&.
.sp
The above two configuration variables can be given to a pattern\&. For example, this sets non\-default expiry values only to remote\-tracking branches:
.sp
.if n \{\
.RS 4
.\}
.nf
[gc "refs/remotes/*"]
        reflogExpire = never
        reflogExpireUnreachable = 3 days
.fi
.if n \{\
.RE
.\}
.sp
.sp
The optional configuration variable \fIgc\&.rerereResolved\fR indicates how long records of conflicted merge you resolved earlier are kept\&. This defaults to 60 days\&.
.sp
The optional configuration variable \fIgc\&.rerereUnresolved\fR indicates how long records of conflicted merge you have not resolved are kept\&. This defaults to 15 days\&.
.sp
The optional configuration variable \fIgc\&.packRefs\fR determines if \fIgit gc\fR runs \fIgit pack\-refs\fR\&. This can be set to "notbare" to enable it within all non\-bare repos or it can be set to a boolean value\&. This defaults to true\&.
.sp
The optional configuration variable \fIgc\&.aggressiveWindow\fR controls how much time is spent optimizing the delta compression of the objects in the repository when the \-\-aggressive option is specified\&. The larger the value, the more time is spent optimizing the delta compression\&. See the documentation for the \-\-window\(aq option in \fBgit-repack\fR(1) for more details\&. This defaults to 250\&.
.sp
Similarly, the optional configuration variable \fIgc\&.aggressiveDepth\fR controls \-\-depth option in \fBgit-repack\fR(1)\&. This defaults to 250\&.
.sp
The optional configuration variable \fIgc\&.pruneExpire\fR controls how old the unreferenced loose objects have to be before they are pruned\&. The default is "2 weeks ago"\&.
.SH "NOTES"
.sp
\fIgit gc\fR tries very hard to be safe about the garbage it collects\&. In particular, it will keep not only objects referenced by your current set of branches and tags, but also objects referenced by the index, remote\-tracking branches, refs saved by \fIgit filter\-branch\fR in refs/original/, or reflogs (which may reference commits in branches that were later amended or rewound)\&.
.sp
If you are expecting some objects to be collected and they aren\(cqt, check all of those locations and decide whether it makes sense in your case to remove those references\&.
.SH "HOOKS"
.sp
The \fIgit gc \-\-auto\fR command will run the \fIpre\-auto\-gc\fR hook\&. See \fBgithooks\fR(5) for more information\&.
.SH "SEE ALSO"
.sp
\fBgit-prune\fR(1) \fBgit-reflog\fR(1) \fBgit-repack\fR(1) \fBgit-rerere\fR(1)
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite
